<template>
  <div>
      <h2>用户详细信息完善页面</h2>
      <table border="1">
        <tr>
          <td>真实姓名</td>
          <td>
            <input type="text" v-model="info.xname">
          </td>
        </tr>
        <tr>
          <td>联系方式</td>
          <td>
            <input type="text" v-model="info.xphone">
          </td>
        </tr>
        <tr>
          <td>出生日期</td>
          <td>
            <input type="date" v-model="info.xdate">
          </td>
        </tr>
        <tr>
          <td>性别</td>
          <td>
            <input type="radio" name="sex" value="男" checked v-model="info.xsex">男
            <input type="radio" name="sex" value="女" v-model="info.xsex">女
          </td>
        </tr>
        <tr>
          <td>年收入</td>
          <td>
            <input type="text" v-model="info.year">
          </td>
        </tr>
        <tr>
          <td>身份证号</td>
          <td>
            <input type="text" v-model="info.xcard">
          </td>
        </tr>
        <tr>
          <td>用户类型编号</td>
          <td>
            <input type="radio" name="type" value="管理员" checked v-model="info.xtype">管理员
            <input type="radio" name="type" value="普通用户" v-model="info.xtype">普通用户
          </td>
        </tr>
        <tr>
          <td colspan="2" style="text-align: center;">
            <input type="button" value="完善" @click="Add()">
          </td>

        </tr>
      </table>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios'
import { useRouter } from 'vue-router';
const router = useRouter()
const info=ref({
  xname:"",
  xphone:"",
  xdate:"",
  xsex:"",
  year:"",
  xcard:"",
  xtype:"",

})
//完善
const Add=()=>{
  if(info.value.xname=="")
  {
    alert("真实姓名不能为空")
    return;
  }
  if(info.value.xphone=="")
  {
    alert("联系方式不能为空")
    return;
  }
  if(info.value.year=="")
  {
    alert("年收入不能为空")
    return;
  }
  if(info.value.xcard=="")
  {
    alert("身份证号不能为空")
    return;
  }
  axios({
    url:"http://localhost:18964/api/CF/Addd",
    method:"post",
    data:info.value
  }).then(res=>{
    if(res.data>0)
    {

      alert("完善成功")
      if(info.value.xtype=="管理员")
      {
          router.push("YonghuView.vue")
      }
      else
      {
        router.push("GuanliView.vue")
      }
    }
    else
    {
      alert("完善失败")
    }
  })
}

</script>

<style scoped>

</style>